package com.mmy.service.impl.sys;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.sys.HeaderRepository;
import com.mmy.domain.permissionmenu.TConstMenu;
import com.mmy.service.sys.HeaderService;

@Service
public class HeaderServiceImpl implements HeaderService {

	@Autowired
	HeaderRepository headerRepository;

	/**
	 * 查找前台全部
	 * 
	 * @param
	 * @return
	 */
	public Map<String, Object> findFrontMenu() {
		
		Map<String, Object> data = new HashMap<>();

		List<TConstMenu> lstId = headerRepository.getFrontMenuByID();
		for (TConstMenu lst : lstId) {
			List<TConstMenu> tConstMenuByMenuID = headerRepository.getChildrenByMenuID(lst.getMenuID());
			lst.setChildrens(tConstMenuByMenuID);
		}
		data.put("menu", lstId);
		return data;

	}

	/**
	 * 查找无权限
	 * 
	 * @param
	 * @return
	 */
	public Map<String, Object> findMenu() {
		
		Map<String, Object> data = new HashMap<>();
		List<TConstMenu> lstId = headerRepository.getMenuByID();
		data.put("menu", lstId);
		return data;
	}

	/**
	 * 查找后台全部
	 * 
	 * @param
	 * @return
	 */
	public Map<String, Object> findBackMenu() {
		// TODO Auto-generated method stub

		Map<String, Object> data = new HashMap<>();

		List<TConstMenu> lstId = headerRepository.getBackMenuByID();
		for (TConstMenu lst : lstId) {
			List<TConstMenu> tConstMenuByMenuID = headerRepository.getChildrenByMenuID(lst.getMenuID());
			lst.setChildrens(tConstMenuByMenuID);
		}
		data.put("menu", lstId);
		return data;

	}

	/**
	 * 查找前台
	 * 
	 * @param
	 * @return
	 */

	public Map<String, Object> findFrontByID(int iUserID) {
		// TODO Auto-generated method stub
		Map<String, Object> data = new HashMap<>();

		List<TConstMenu> lstId = headerRepository.findFrontByID(iUserID);
		for (TConstMenu lst : lstId) {
			List<TConstMenu> tConstMenuByMenuID = headerRepository.getChildrenByMenuID(lst.getMenuID());
			lst.setChildrens(tConstMenuByMenuID);
		}
		data.put("menu", lstId);
		return data;
	}

	/**
	 * 查找后台
	 * 
	 * @param
	 * @return
	 */
	public Map<String, Object> findBackByID(int iUserID) {
		
		Map<String, Object> data = new HashMap<>();
		List<TConstMenu> lstId = headerRepository.findBackByID(iUserID);
		for (TConstMenu lst : lstId) {
			List<TConstMenu> tConstMenuByMenuID = headerRepository.getChildrenByMenuID(lst.getMenuID());
			lst.setChildrens(tConstMenuByMenuID);
		}
		data.put("menu", lstId);
		return data;
	}


}
